package listeners

import (
	"fmt"
	"gin_study/app/event_manager"
	"gin_study/app/events"
)

type PrintNameAfterFetchUserListener struct {
	events []interface{}
}

func (p *PrintNameAfterFetchUserListener) Handler(e interface{}) {
	if va, ok := e.(events.FetchUserEvent); ok {
		fmt.Println(va.Name, "PrintNameAfterFetchUserListener")
	}
}

func (p *PrintNameAfterFetchUserListener) SetEvents() {
	p.events = append(p.events, events.FetchUserEvent{})
}

func (p *PrintNameAfterFetchUserListener) GetListenerEvents() []interface{} {
	return p.events
}

func init() {
	p := new(PrintNameAfterFetchUserListener)
	event_manager.EM.Register(p)
}
